import request from '@/utils/request'

export default {

    /**
     * 课程章节树形结构列表
     * @param {string} courseId 课程ID
     * @returns 
     */
    tree(courseId) {
        return request({
            url:    `/edu/chapter/tree/${courseId}`,
            method: 'get'
        })
    },

    /**
     * 添加课程章节
     * @param {object} chapterObj 课程章节对象
     * @returns 
     */
    add(chapterObj) {
        return request({
            url:    `/edu/chapter/save`,
            method: 'post',
            data:   chapterObj
        })
    },

    /**
     * 根据ID查询课程章节
     * @param {string} id 课程章节ID
     * @returns 
     */
    getById(id) {
        return request({
            url:    `/edu/chapter/${id}`,
            method: 'get'
        })
    },

    /**
     * 修改课程章节
     * @param {object} chapterObj 课程章节对象
     * @returns 
     */
    update(chapterObj) {
        return request({
            url:    `/edu/chapter/${chapterObj.id}`,
            method: 'put',
            data:   chapterObj
        })
    },

    /**
     * 删除课程章节
     * @param {string} id 课程章节ID
     * @returns 
     */
    remove(id) {
        return request({
            url:    `/edu/chapter/${id}`,
            method: 'delete'
        })
    }

}

